package longshu.data.controller;

import longshu.data.common.ds.DataSourceKey;
import longshu.data.common.ds.DynamicDataSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * IndexController
 *
 * @author LongShu 2018/01/19
 */
@RequestMapping("/")
@Controller
public class IndexController {

    /**
     * 测试
     */
    @RequestMapping("/test")
    @ResponseBody
    public Object test(@RequestParam(defaultValue = DataSourceKey.H2) String ds) {
        // 切换数据源
        DynamicDataSource.setDataSourceKey(ds);

        return DynamicDataSource.currentDataSource().toString();
    }

}
